Page({
  data: {
    feedbackText: '' ,
		 boxShadow: []
  },
	onReady: function() {
    this.applyShadows();
  },

  inputFeedback: function(e) {
    this.setData({
      feedbackText: e.detail.value  
    });
  },
  submitFeedback: function() {
    const feedback = this.data.feedbackText;  
    wx.request({
      url: 'http://localhost:8001/user/feedback',//连接服务器
      method: 'POST',
      data: {
        content: feedback
      },
      success: function(res) {
        console.log('反馈提交成功');
        wx.showToast({
          title: '提交成功',
          icon: 'success',
					duration: 2000,
					success: function() {
						wx.navigateTo({
							url: '/pages/mine/mine' 
						});
					}
        });
      },
      fail: function(err) {
        console.error('反馈提交失败', err);
        wx.showToast({
          title: '提交失败，请重试',
          icon: 'none',
          duration: 2000
        });
      }
    });
  },
applyShadows: function() {
    const query = wx.createSelectorQuery();
    query.selectAll('.backgrounds1').boundingClientRect((rects) => {
      const boxShadows = rects.map((rect, index) => {
        let shadows = '';
        let count = 500 / (index + 1);
        let light = 1;
        for (let i = 1; i <= count; i++) {
          const offsetX = this.getRandomInt(1, 100);
          const offsetY = this.getRandomInt(1, -100);
          shadows += `${offsetX}vw ${offsetY}vh #FFCCCC, `;
        }
        return shadows.slice(0, -2); 
      });

      this.setData({
        boxShadow: boxShadows
      });
    }).exec();
  },
  getRandomInt: function(min, max) {
    return Math.floor(Math.random() * (max - min + 1)) + min;
  }
});
